<!--
 * @Author: 龙雨欢 932838577@qq.com
 * @Date: 2023-10-06 11:59:39
 * @LastEditors: 龙雨欢 932838577@qq.com
 * @LastEditTime: 2023-10-24 11:07:37
 * @FilePath: \sxyd-vue\src\components\nenghao\enterprises.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
    <div style="text-align: center;">
        <h3 style="text-align: center;">重污染绩效分级指标</h3>
        <el-form :inline="true">
            <el-form-item label="行业类型">
                <el-select v-model="hangyeleixing" filterable placeholder="请选择行业类型" style="width: 100%"
                    @change="changeHangye($event)">
                    <el-option v-for="item in hangyeData" :key="item.value" :label="item.label" :value="item.value">
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="差异化指标">
                <el-select v-model="chayihuazhibiao" filterable placeholder="请选择差异化指标" style="width: 100%"
                    @change="changeChayihua($event)">
                    <el-option v-for="item in chayihuaData" :key="item.value" :label="item.label" :value="item.value">
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="具体指标">
                <el-select v-model="jutizhibiao" filterable placeholder="请选择具体指标" style="width: 100%"
                    @change="changeJuti($event)">
                    <el-option v-for="item in jutiData" :key="item.value" :label="item.label" :value="item.value">
                    </el-option>
                </el-select>
            </el-form-item>
        </el-form>
        <el-table :data="tableData" stripe style="width: 60%;margin-left: 20%;">
            <el-table-column prop="ajqy" label="A级企业" width="240" align="center">
            </el-table-column>
            <el-table-column prop="bjqy" label="B级企业" width="240"  align="center">
            </el-table-column>
            <el-table-column prop="cjqy" label="C级企业" width="220"  align="center">
            </el-table-column>
            <el-table-column prop="djqy" label="D级企业" width="200"  align="center">
            </el-table-column>
            <el-table-column prop="zbbz" label="备注"  align="center">
            </el-table-column>
        </el-table>
        <h3 style="text-align: center;">重污染引领性指标</h3>
        <el-form :inline="true">
            <el-form-item label="行业类型">
                <el-select v-model="hangyeleixing2" filterable placeholder="请选择行业类型" style="width: 100%"
                    @change="changeHangye2($event)">
                    <el-option v-for="item in hangyeData2" :key="item.value" :label="item.label" :value="item.value">
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="引领性指标">
                <el-select v-model="chayihuazhibiao2" filterable placeholder="请选择引领性指标" style="width: 100%"
                    @change="changeChayihua2($event)">
                    <el-option v-for="item in chayihuaData2" :key="item.value" :label="item.label" :value="item.value">
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="具体指标">
                <el-select v-model="jutizhibiao2" filterable placeholder="请选择具体指标" style="width: 100%"
                    @change="changeJuti2($event)">
                    <el-option v-for="item in jutiData2" :key="item.value" :label="item.label" :value="item.value">
                    </el-option>
                </el-select>
            </el-form-item>
        </el-form>
        <el-table :data="tableData2" stripe style="width: 50%;margin-left: 25%;">
            <el-table-column prop="jtyq" label="具体要求" width="640" align="center">
            </el-table-column>
            <el-table-column prop="bz" label="备注"  align="center">
            </el-table-column>
        </el-table>
    </div>
</template>

<script>
export default {
    name: 'enterprises',
    data() {
        return {
            hangyeleixing: '',
            hangyeData: [],
            chayihuazhibiao: '',
            chayihuaData: [],
            jutizhibiao: '',
            jutiData: [],
            tableData: [],
            hangyeleixing2: '',
            hangyeData2: [],
            chayihuazhibiao2: '',
            chayihuaData2: [],
            jutizhibiao2: '',
            jutiData2: [],
            tableData2: []
        }
    },
    methods: {
        async changeHangye(e) {
            this.chayihuazhibiao=''
            this.jutizhibiao=''
            const { data: res } = await this.$http.post('/v1.0/resultIntegration/rule/jxfjzbb/findPages', {
                cyhzb: '',
                hylx: this.hangyeleixing,
                jtzb: '',
                pageNumber: 1,
                pageSize: 9999,
            })
            let data=[]
            for (let i in res.data.result) {
                data.push(res.data.result[i].cyhzb)
            }
            data = Array.from(new Set(data))
            for (let j in data) {
                this.chayihuaData.push({
                    label: data[j],
                    value: data[j]
                })
            }
        },
        async changeChayihua(e) {
            if (this.hangyeleixing == '') {
                return this.$message.error('请先选择行业类型！')
            }
            this.jutizhibiao=''
            const { data: res } = await this.$http.post('/v1.0/resultIntegration/rule/jxfjzbb/findPages', {
                cyhzb: this.chayihuazhibiao,
                hylx: this.hangyeleixing,
                jtzb: '',
                pageNumber: 1,
                pageSize: 9999,
            })
            let data=[]
            for (let i in res.data.result) {
                if(res.data.result[i].jtzb!=null){
                    data.push(res.data.result[i].jtzb)
                }
            }
            if(data.length==0){
                this.tableData=res.data.result
            }else{
                data = Array.from(new Set(data))
                for (let j in data) {
                this.jutiData.push({
                    label: data[j],
                    value: data[j]
                })
            }
            }
        },
        async changeJuti(e) {
            if (this.chayihuazhibiao == '') {
                return this.$message.error('请先选择差异化指标！')
            }
            const { data: res } = await this.$http.post('/v1.0/resultIntegration/rule/jxfjzbb/findPages', {
                cyhzb: this.chayihuazhibiao,
                hylx: this.hangyeleixing,
                jtzb: this.jutizhibiao,
                pageNumber: 1,
                pageSize: 9999,
            })
            this.tableData=res.data.result
        },
        async changeHangye2(e) {
            this.chayihuazhibiao2=''
            this.jutizhibiao2=''
            const { data: res } = await this.$http.post('/v1.0/resultIntegration/rule/ylxzbb/findPages', {
                ylxzb: '',
                hylx: this.hangyeleixing2,
                jtzb: '',
                pageNumber: 1,
                pageSize: 9999,
            })
            this.tableData2=[]
            this.chayihuaData2=[]
            let data=[]
            for (let i in res.data.result) {
                data.push(res.data.result[i].ylxzb)
            }
            data = Array.from(new Set(data))
            for (let j in data) {
                this.chayihuaData2.push({
                    label: data[j],
                    value: data[j]
                })
            }
        },
        async changeChayihua2(e) {
            if (this.hangyeleixing2 == '') {
                return this.$message.error('请先选择行业类型！')
            }
            this.jutizhibiao2=''
            const { data: res } = await this.$http.post('/v1.0/resultIntegration/rule/ylxzbb/findPages', {
                ylxzb: this.chayihuazhibiao2,
                hylx: this.hangyeleixing2,
                jtzb: '',
                pageNumber: 1,
                pageSize: 9999,
            })
            let data=[]
            for (let i in res.data.result) {
                if(res.data.result[i].jtzb!=null){
                    data.push(res.data.result[i].jtzb)
                }
            }
            this.jutiData2=[]
            if(data.length==0){
                this.tableData2=res.data.result
            }else{
                data = Array.from(new Set(data))
                for (let j in data) {
                this.jutiData2.push({
                    label: data[j],
                    value: data[j]
                })
            }
            this.tableData2=[]
            }
        },
        async changeJuti2(e) {
            if (this.chayihuazhibiao2 == '') {
                return this.$message.error('请先选择差异化指标！')
            }
            const { data: res } = await this.$http.post('/v1.0/resultIntegration/rule/ylxzbb/findPages', {
                ylxzb: this.chayihuazhibiao2,
                hylx: this.hangyeleixing2,
                jtzb: this.jutizhibiao2,
                pageNumber: 1,
                pageSize: 9999,
            })
            this.tableData2=res.data.result
        },
    },
    async created() {
        const { data: res } = await this.$http.get('/v1.0/resultIntegration/rule/jxfjzbb/findAll')
        let data0 = []
        for (let i in res.data) {
            data0.push(res.data[i].hylx)
        }
        data0 = Array.from(new Set(data0))
        for (let j in data0) {
            this.hangyeData.push({
                label: data0[j],
                value: data0[j]
            })
        }
        const { data: res2 } = await this.$http.get('/v1.0/resultIntegration/rule/ylxzbb/findAll')
        let data2 = []
        for (let x in res2.data) {
            data2.push(res2.data[x].hylx)
        }
        data2 = Array.from(new Set(data2))
        for (let y in data2) {
            this.hangyeData2.push({
                label: data2[y],
                value: data2[y]
            })
        }
    },
    watch: {

    }
}
</script>

<style lang="less" scoped>

</style>
